/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.CustomerInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerFieldManager;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.util.List;
/*    */ import javax.servlet.RequestDispatcher;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ShowUpdateCompany extends AbstractAction
/*    */ {
/* 26 */   private static Logger logger = Logger.getLogger(ShowUpdateCompany.class
/* 27 */     .getName());
/*    */ 
/* 29 */   private int id = 0;
/*    */ 
/*    */   public ShowUpdateCompany(AbstractHttpServlet servlet) {
/* 32 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public ShowUpdateCompany(AbstractHttpServlet servlet, String id) {
/* 36 */     super(servlet);
/* 37 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 44 */     CustomerManager manager = new CustomerManager();
/*    */     try {
/* 46 */       CustomerInfo customerInfo = manager.getCustomerInfo(this.id, false, 
/* 47 */         true);
/* 48 */       if (customerInfo == null) {
/* 49 */         throw new NotFoundException();
/*    */       }
/* 51 */       if (customerInfo.type != 0)
/*    */       {
/* 53 */         throw new NotFoundException();
/*    */       }
/*    */ 
/* 56 */       User user = super.getLoginUser(request);
/*    */ 
/* 58 */       String ip = Util.getClientIpAddr(request);
/* 59 */       logger.warn("ip:" + ip + " / 用户Id：" + user.userId + " /  用户名：" + 
/* 60 */         user.name + ", 浏览了公司：id:  " + customerInfo.id + " / 名称：" + 
/* 61 */         customerInfo.name);
/*    */ 
/* 65 */       if (!customerInfo.hasModifyRight(user, 
/* 65 */         super.getCompany(user.companyId).users)) {
/* 66 */         request.getRequestDispatcher("/nopermission.jsp").forward(
/* 67 */           request, response);
/* 68 */         return;
/*    */       }
/*    */ 
/* 71 */       CustomerFieldManager fieldManager = new CustomerFieldManager();
/*    */ 
/* 73 */       List fields = fieldManager.list(
/* 74 */         user.companyId, 1);
/* 75 */       request.setAttribute("fields", fields);
/* 76 */       request.setAttribute("customerInfo", customerInfo);
/* 77 */       request.getRequestDispatcher("/company_modify.jsp").forward(
/* 78 */         request, response);
/*    */     } catch (DBException e) {
/* 80 */       logger.warn("get company detail failed", e);
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowUpdateCompany
 * JD-Core Version:    0.6.1
 */